package t_1723

import "sort"

func minimumTimeRequired(jobs []int, k int) int {

	// given
	//输入：jobs = [1,2,4,7,8], k = 2
	//输出：11
	context := make([]int, k)
	sort.Ints(jobs)
	length := len(jobs)
	for i := length - 1; i > -1; i-- {
		sort.Ints(context)
		context[0] = context[0] + jobs[i]
	}

	sort.Ints(context)
	return context[k-1]
}
